<template>
  <div class="dormitory-details">
    <div class="dormitory-details__dormitory-photo">
      <el-carousel :interval="5000" arrow="always" height="120px">
        <el-carousel-item
          v-for="(image, index) in photoFormat"
          :key="index"
        >
          <el-image :src="image" style="width: 100%;height: 100%" fit="cover" />
        </el-carousel-item>
      </el-carousel>
    </div>
    <div class="dormitory-details__info">
      <div class="dormitory-details__info__address local">
        <svg-icon icon-class="local" class-name="local__icon" />
        <span class="local__value">{{ details?.address }}</span>
      </div>
      <div class="dormitory-details__info__data data">
        <div
          v-for="(item, index) in detailsData"
          :key="index"
          class="data__item"
        >
          <svg-icon :icon-class="item.icon" class-name="data__item--icon" />
          <div class="data__item__data">
            <div class="data__item__data__value">{{ item.value }}</div>
            <div class="data__item__data__key">{{ item.title }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: '',
  props: {
    details: {
      type: Object,
      default: () => ({})
    },
    detailsData: {
      type: Array,
      default: () => ([])
    }
  },
  data() {
    return {

    }
  },
  computed: {
    photoFormat() {
      const photo = this.details?.photo
        ? JSON.parse(this.details?.photo) : []
      return Array.isArray(photo) && photo.length > 0 ? photo : []
    }
  }
}
</script>
<style lang="scss" scoped>
$textColor: #3D3D3D;
.dormitory-details {
  padding: 20px;
  background-color: #fff;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  border-radius: 4px;

  &__dormitory-photo {
    margin-right: 32px;
    width: 160px;
    height: 120px;
    border-radius: 4px;
    overflow: hidden;
  }

  &__info {

    .local {
      &__icon {
        font-size: 22px;
      }
      &__value {
        color: $textColor;
        font-size: 16px;
        font-weight: 400;
      }
    }

    .data {
      margin-top: 32px;
      display: flex;
      &__item {
        display: flex;
        min-width: 178px;
        &--icon {
          font-size: 58px;
        }

        &__data {
          margin-left: 16px;
          margin-right: 40px;
          display: flex;
          flex-direction: column;
          justify-content: space-between;

          &__key {
            color: $textColor;
            font-size: 14px;
            font-weight: 400;
          }

          &__value {
            color: $textColor;
            font-size: 24px;
            font-weight: 700;
          }

        }

      }
    }

  }
}
::v-deep(.el-carousel__arrow) {
  width: 20px;
  height: 20px;
  font-size: 10px;

  .el-icon-arrow-left,
  .el-icon-arrow-right {
    font-size: 10px;
  }
}
::v-deep(.el-carousel__arrow--left) {
  left: 10px;
}

::v-deep(.el-carousel__arrow--right) {
  right: 10px;
}

::v-deep(.el-carousel__button) {
  width: 4px;
  height: 4px;
  border-radius: 50%;
}

</style>
